Skip to content

feat: Add minimum affinity option to locales resolver#28

Merged
ericfjosne merged 4 commits into
mainfrom
feat-Add-requiredAffinity-option-to-LocalesResolver
May 20, 2026
Merged

feat: Add minimum affinity option to locales resolver#28
ericfjosne merged 4 commits into
mainfrom
feat-Add-requiredAffinity-option-to-LocalesResolver

Conversation

@ericfjosne
Copy link
Copy Markdown
Collaborator

@ericfjosne ericfjosne commented May 19, 2026

We are hitting an issue with the current setup, where the default behavior for the ICU LocaleMatcher promotes locales which are too distant from what we consider as an acceptable best match.

Examples:

  • Norwegian Bokmål nb is promoted as best matching locale for Danish da.
  • Indonesian id gets promoted as best matching locale for Malay ms.
  • Russian ru gets promoted as best matching locale for Kazakh kk and Mongolian mn.

We would like to enable some level of control over the matching logic. We suggest adding a new minimumLocaleAffinity configuration option, which builds on the locale affinity logic implemented previously.

In order to not break existing integrations, we need to set a default value for this new configuration option. We decided to set it to MUTUALLY_INTELLIGIBLE define over here.

@ericfjosne ericfjosne changed the title feat: Add required affinity option to locales resolver feat: Add minimum affinity option to locales resolver May 20, 2026
@ericfjosne
Copy link
Copy Markdown
Collaborator Author

For now, I made 2 changes to the PR:

  • requiredLocaleAffinity -> minimumLocaleAffinity: The "required" name felt like it might imply we want this specific affinity level only, while the implementation is about ensuring that we return a resolve locale which meets a minimum locale affinity threshold.
  • I made minimumLocaleAffinity() (both class & builder methods) package private for now, because there are discrepancies between the locale affinity calculation implementation, and the resolver. I would want all results to be aligned before releasing this as something anyone can configure.

@ericfjosne ericfjosne merged commit 801c402 into main May 20, 2026
1 check passed
@ericfjosne ericfjosne deleted the feat-Add-requiredAffinity-option-to-LocalesResolver branch May 20, 2026 11:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants